﻿using System;
using System.Security.Cryptography.X509Certificates;

namespace mengqiu4
{
    class Program
    {
        public static void findScore(int[] s) {
            Console.Write("请输入学号：");
            int num = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("{0}号同学的分数为：{1}",num,s[num-1]);
        }
        public static void findMax(int[] s)
        {
            int max = s[0];
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] > max) { max = s[i]; }
            }
            Console.WriteLine("最高分为：{0}", max);
        }
        public static void findMin(int[] s)
        {
            int min = s[0];
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] < min) { min = s[i]; }
            }
            Console.WriteLine("最低分为：{0}", min);
        }
        public static void findAve(int[] s)
        {
            int sum = 0;
            for(int i=0;i<s.Length;i++)
            {
                sum += s[i];
            }
            float ave = (float)sum / (float)s.Length;
            Console.WriteLine("最低分为：{0}", ave);
        }
        public static void aBaABa()
        {
            Console.Write("输入任意长度的字符串：");
            String abaaba = Console.ReadLine();
            Console.Write("输入需要查找的字符串：");
            String aba = Console.ReadLine();
            string[] abaArr = abaaba.Split(aba);
            Console.WriteLine("要查找的字符串出现次数为：{0}",abaArr.Length - 1);
        }
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.DarkGray ;
            Console.BackgroundColor = ConsoleColor.White;
            Console.Clear();
            int[] score = new int[30] { 81, 70, 68, 67, 73, 82, 66, 75, 62, 83, 76, 82, 94, 91, 72, 57, 73, 56, 58, 87, 63, 70, 56, 75, 64, 84, 58, 91, 80, 71 };
            int choose = 1;
            while (choose != 0)
            {
                Console.WriteLine("菜单");
                Console.WriteLine("1-查询成绩");
                Console.WriteLine("2-最高分");
                Console.WriteLine("3-最低分");
                Console.WriteLine("4-平均分");
                Console.WriteLine("5-***前往验证第二题***");
                Console.WriteLine("0-退出");
                choose = Convert.ToInt32(Console.ReadLine());
                if (choose == 0) { Console.Clear(); break; }
                switch (choose)
                {
                    case 1: findScore(score); break;
                    case 2: findMax(score); break;
                    case 3: findMin(score); break;
                    case 4: findAve(score); break;
                    case 5: aBaABa();break;
                    default: Console.WriteLine("****输入的数字不对劲****"); break;
                }
                Console.WriteLine("****按回车键返回首页****");
                Console.ReadLine();
                Console.Clear();
            }
            
        }
    }
}